home *** CD-ROM | disk | FTP | other *** search
/ Aminet 39 / Aminet 39 (2000)(Schatztruhe)[!][Oct 2000].iso / Aminet / util / misc / ReqAttackUpd.lha / ReqAttackUpd / ReqOFF-Bonus / RODreamSound.e < prev    next >
Encoding:
Text File  |  1992-07-23  |  2.9 KB  |  64 lines

  1. /* Example sound player. It reads the command from ENV:RODreamSound and
  2.    adds the sample to play at the end of the string, so the variable in
  3.    ENV: sould be for example 'run >nil: c:xplay nfl sounds=' (without
  4.    quotas of course). This isn't a proper way to play samples with ReqAttack,
  5.    but I understand that RASoundDeamon which uses datatypes isn't very
  6.    good either.
  7.  
  8.    Program suggested by BKJ (Vulture@freemail.gr).
  9.  
  10.    IMPORTANT: To protect ReqOFF againts going into infinitive loop (when your
  11.    requester replacer calls EasyRequestArgs() with same TITLE and/or TEXT
  12.    as the original requester) you should add a single space as a first byte
  13.    of title string, or simply change it to other title which will not qualify
  14.    to be patched by your program again and again and again...
  15.  
  16.    IMPORTANT: In 'replacerdata' structure you receive not only the easystruc,
  17.    but also the screen pointer, idcmp and args with which the main
  18.    EasyRequestArgs was called. The 1st thing is that is not guaranteed that the
  19.    screen is still opened (I think it's better to call EasyRequestArgs() with
  20.    a NIL/NULL screen pointer because all users probably use DefaultPubScreen
  21.    patches). The 2nd is that idcmp and args may be passed incorrectly by
  22.    ReqOFF/other software (???) because mine programs hanged with these args
  23.    passed to EasyRequestArgs - so don't use them!
  24. */
  25.  
  26. MODULE 'dos/dos','intuition/intuition','other/replacer'
  27.  
  28. DEF pos
  29. DEF newtitle:PTR TO LONG,exit=0,fh,file[1501]:STRING,fib[260]:ARRAY OF CHAR,fibl:PTR TO fileinfoblock
  30. DEF file2[1001]:STRING,re:PTR TO replacerdata
  31.  
  32. PROC main()
  33. IF fh:=Open('ENV:RODreamSound.prefs',MODE_OLDFILE)
  34.   ExamineFH(fh,fib);fibl:=fib         ->  read the command to execute...
  35.   Read(fh,file,fibl.size)
  36.   file[fibl.size+1]:=NIL
  37.   Close(fh)
  38.  
  39.   IF StrCmp(arg,'"',1)                ->  the 1st arg is sample name
  40.     pos:=InStr(arg,'"',1)             ->  which has to be specified in
  41.     StrCopy(file2,arg,pos)            ->  RAPrefsMUI
  42.   ELSE
  43.     pos:=InStr(arg,' ',1)
  44.     StrCopy(file2,arg,pos)            ->  now the file variable contains
  45.   ENDIF                               ->  the file name
  46.  
  47.   StringF(file,'\s \s',file,file2)
  48. ENDIF
  49.  
  50.   pos:=InStr(arg,'0x',0)              ->  replace all 0x with ' $'
  51.   arg[pos]:=$20;arg[pos+1]:=$24       ->  Val() needs hexadecimal numbers...
  52.   re:=Val(arg+pos,0)                  ->  (get the value)
  53.                                       ->  ...to be preceded by '$'
  54.  
  55.   IF newtitle:=New(StrLen(re.easystr.title)+2)->  title MUST be preceded by a space
  56.                                       ->  we do not want an infinitive loop!
  57.     StringF(newtitle,' \s',re.easystr.title)
  58.                                       ->  run the command...
  59.     SystemTagList(file,NIL)
  60.                                       ->  now call the requester...
  61.     exit:=EasyRequestArgs(0,[20,0,newtitle,re.easystr.textformat,re.easystr.gadgetformat],0,0)
  62.   ENDIF
  63. ENDPROC exit
  64.